﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Iacym.Entities;

namespace Iacym.Repository
{
    public class DetalleCitasRepository : MasterRepository, IDetalleCitasRepository
    {
        public List<DETALLE_CITA> GetAllFromDetalleCitasByPersonaId(int id)
        {
            var query = from p in context.DETALLE_CITA.Include("Agendum")
                        where p.Agendum.PersonaId.Equals(id)
                        orderby p.Agendum.FechaInicio descending
                        select p;

            return query.ToList();
        }


        public void AddDetalleCitas(DETALLE_CITA detalleCita)
        {
            //context.Entry(detalleCita.Agendum).State = System.Data.EntityState.Unchanged;
            context.DETALLE_CITA.Add(detalleCita);
            context.SaveChanges();
        }
    }
}
